package E2014;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
public class Exam3 {
    public static void findStringFile(String fileName,String subStr) throws Exception{

        Map<Integer,String> map = new HashMap();
        FileReader fileReader = new FileReader(fileName);
        BufferedReader buffer = new BufferedReader(fileReader);
        String str = null;
        int line = 0;
        while ((str=buffer.readLine())!=null){
            line++;
            if (str.contains(subStr)){
                map.put(line,str);
            }
        }
        Iterator iter = map.entrySet().iterator();
        while(iter.hasNext()){
            Entry entry = (Entry) iter.next();
            Object key = entry.getKey();
            Object value = entry.getValue();
            System.out.println(key+":"+value);
        }
    }
    public static void main(String[] args) throws Exception {
        findStringFile("src/E2014/test","time");
    }

}
